package org.example.order.case4;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.List;

/**
 * 验证@Order对集合中排序的影响
 *
 * @author lizongyang
 * @date 2023/09/18
 */
@Slf4j
public class OrderMain {
    public static void main(String[] args) {
        log.info("========验证@Order对bean执行顺序的影响========");
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        // 设置扫描路径
        context.scan("org.example.order.case4");
        // 刷新
        context.refresh();
        // 获取 继承了OrderTestBase的 bean 的集合
        log.info("========验证@Order对集合中排序的影响========");
        List<OrderTestBase> beanFactoryPostProcessor = context.getBean(BeanFactoryPostProcessorUtil.class).getBeanFactoryPostProcessor();
        for (OrderTestBase e : beanFactoryPostProcessor) {
            e.orderList();
        }
    }
}